package io.renren.param;

import io.renren.entity.SeatEntity;
import io.renren.group.UpdateGroup;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

@Data
public class SeatUpdateParam {
    /* 1=管理员用户；2=普通用户 */
    public static final int ADMIN_USER_TYPE = 1;
    public static final int NORMAL_USER_TYPE = 2;

    public boolean isAdminUser() {
        return null != userType && userType == ADMIN_USER_TYPE;
    }

    public boolean isNormalUser() {
        return null != userType && userType == NORMAL_USER_TYPE;
    }

    private Long id;

    /* 用来保存员工每天或每周的 工作目标 */
    private String workTarget;

    /**
     * 工位编号
     */
    private String code;
    /**
     * 工位名称
     */
    private String name;
    /**
     * 工位所属的企业id
     */
    private String compId;

    @NotBlank(message = "操作员id不能为空", groups = {UpdateGroup.class})
    private String userId;

    @NotNull(message = "用户类型不能为空", groups = {UpdateGroup.class})
    private Integer userType;
    /**
     * 城市
     */
    private String city;
    /**
     * 工位楼层
     */
    private String floor;
    /**
     * 工位类型。fixed-固定；share-共享
     */
    private String type;
    /**
     * 工位状态 unusable表示维修 usable表示可用
     */
    private String state;
    /**
     * AP id
     */
    private String apId;
    /**
     * 价签id
     */
    @NotBlank(message = "价签id不能为空", groups = {UpdateGroup.class})
    private String eslId;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 更新时间
     */
    private Date updateTime;
    /**
     * 省份
     */
    private String province;
    /**
     * 预定工位的员工部门
     */
    private String department;
    /**
     * 预定工位的员工id
     */
    private String employeeId;
    /**
     * 预定工位的员工工号
     */
    private String employeeCode;
    /**
     * 预定工位的员工邮箱
     */
    private String email;
    /**
     * 是否党员
     */
    private Boolean isPartyMember;

    public static SeatEntity convertFor(SeatUpdateParam param) {
        SeatEntity seatEntity = new SeatEntity();
        BeanUtils.copyProperties(param, seatEntity);
        seatEntity.setCreateTime(new Date());
        seatEntity.setUpdateTime(new Date());
        return seatEntity;
    }
}
